GenomicPlot 0.99.5
Visualization of next generation sequencing (NGS) data at various genomic features on a genome-wide scale provides an effective way of exploring and communicating experimental results on one hand, yet poses as a tremendous challenge on the other hand, due to the huge amount of data to be processed. Existing software tools like deeptools, ngs.plot, coverageView and metagene2, while having attractive features and perform reasonably well in relatively simple scenarios, like plotting coverage profiles of fixed genomic loci or regions, have serious limitations in terms of efficiency and flexibility. For instance, deeptools requires 3 steps (3 sub-programs to be run) to generate plots from input files: first, convert .bam files to .bigwig format; second, compute coverage matrix; and last, plot genomic profiles. Huge amount of intermediate data are generated along the way and additional efforts have to be made to integrate these 3 closely related steps. All of them focus on plotting signals within genomic regions or around genomic loci, but not within or around combinations of genomic features. None of them have the capability of performing statistical tests on the data displayed in the profile plots.
To meet the diverse needs of experimental biologists, we have developed GenomicPlot using rich resources available on the R platform (particularly, the Bioconductor). Our GenomicPlot has the following major features:
The following packages are prerequisites:
GenomicRanges (>= 1.46.1), GenomicFeatures, Rsamtools, ggplot2 (>= 3.3.5), tidyr, rtracklayer (>= 1.54.0), plyranges (>= 1.14.0), dplyr (>= 1.0.8), cowplot (>= 1.1.1), VennDiagram, ggplotify, GenomeInfoDb, IRanges, ComplexHeatmap, RCAS (>= 1.20.0), scales (>= 1.2.0), GenomicAlignments (>= 1.30.0), edgeR, forcats, circlize, viridis, ggsignif (>= 0.6.3), ggsci (>= 2.9), genomation (>= 1.26.0), ggpubr
You can install the development version from GenomicPlot with:
# install.packages("remotes")
remotes::install_github("shuye2009/GenomicPlot",
build_manual = TRUE,
build_vignettes = TRUE)
Or download the source package from the latest release from GenomicPlot and run in R:
install.packages("path-to-source-package/GenomicPlot_x.x.x.tar.gz",
repos = NULL)
where “path-to-source-package” is the absolute path to the file “GenomicPlot_x.x.x.tar.gz”, substitute ‘x’ with the version number of your downloaded package.
The lengths of each part of the genes are prorated based on the median length of 5’UTR, CDS and 3’UTR of protein-coding genes in the genome. The total length (including upstream and downstream extensions) are divided into the specified number of bins. Subsets of genes can be plotted as overlays for comparison.
library(GenomicPlot, quietly = TRUE)
gtffile <- system.file("extdata", "gencode.v19.annotation_chr19.gtf",
package = "GenomicPlot")
gff <- RCAS::importGtf(saveObjectAsRds = TRUE, filePath = gtffile)
txdb <- makeTxDbFromGRanges(gff)
gf <- prepare_5parts_genomic_features(txdb,
meta = TRUE, nbins = 100, fiveP = -2000, threeP = 1000,
longest = TRUE
)
queryfiles <- system.file("extdata", "treat_chr19.bam", package = "GenomicPlot")
names(queryfiles) <- "clip_bam"
inputfiles <- system.file("extdata", "input_chr19.bam", package = "GenomicPlot")
names(inputfiles) <- "clip_input"
bamimportParams <- list(
offset = -1, fix_width = 0, fix_point = "start", norm = TRUE,
useScore = FALSE, outRle = TRUE, useSizeFactor = FALSE, genome = "hg19"
)
plot_5parts_metagene(
queryFiles = queryfiles,
gFeatures_list = list("metagene" = gf),
inputFiles = inputfiles,
scale = FALSE,
verbose = FALSE,
transform = NA,
smooth = TRUE,
stranded = TRUE,
outPrefix = NULL,
importParams = bamimportParams,
heatmap = TRUE,
rmOutlier = 0,
nc = 5
)
Figure 1: Profile overlay
Figure 2: Ratio-over-input profile and heatmap
The lengths of each part of the profile plot are prorated to the lengths of upstream and downstream extensions as well as the median length of protein-coding genes in the genome. The total length (including upstream and downstream extensions) are divided into the specified number of bins.
gf <- prepare_3parts_genomic_features(txdb,
meta = FALSE, nbins = 100, fiveP = -3000, threeP = 2000,
longest = TRUE
)
queryfiles <- system.file("extdata", "chip_treat_chr19.bam",
package = "GenomicPlot")
names(queryfiles) <- "chip_bam"
inputfiles <- system.file("extdata", "chip_input_chr19.bam",
package = "GenomicPlot")
names(inputfiles) <- "chip_input"
chipimportParams <- list(
offset = 0, fix_width = 150, fix_point = "start", norm = TRUE,
useScore = FALSE, outRle = TRUE, useSizeFactor = FALSE, genome = "hg19"
)
plot_3parts_metagene(
queryFiles = queryfiles,
gFeatures = gf,
inputFiles = inputfiles,
scale = FALSE,
verbose = FALSE,
transform = NA,
smooth = TRUE,
stranded = TRUE,
outPrefix = NULL,
importParams = chipimportParams,
heatmap = TRUE,
rmOutlier = 0,
nc = 5
)
Figure 3: Profile overlay
Figure 4: Ratio-over-input profile and heatmap
Signal profiles along with heatmaps in genomic features or user defined genomic regions provided through a .bed file or narrowPeak file can be plotted. Multiple samples (.bam files) and multiple set of regions (.bed file) can be overlayed on the same figure, or can be output as various combinations. When input files (for input samples) are available, ratio-over-input are displayed as well. Statistical comparisons between samples or between features can be plotted as boxplots or barplots of means±SE.
centerfiles <- system.file("extdata", "test_chip_peak_chr19.narrowPeak",
package = "GenomicPlot")
names(centerfiles) <- c("NarrowPeak")
queryfiles <- c(
system.file("extdata", "chip_treat_chr19.bam", package = "GenomicPlot")
)
names(queryfiles) <- c("chip_bam")
inputfiles <- c(
system.file("extdata", "chip_input_chr19.bam", package = "GenomicPlot")
)
names(inputfiles) <- c("chip_input")
plot_region(
queryFiles = queryfiles,
centerFiles = centerfiles,
inputFiles = inputfiles,
nbins = 100,
heatmap = TRUE,
scale = FALSE,
regionName = "narrowPeak",
importParams = chipimportParams,
verbose = FALSE,
fiveP = -500,
threeP = 500,
smooth = TRUE,
transform = NA,
stranded = TRUE,
outPrefix = NULL,
rmOutlier = 0,
nc = 5
)
Figure 5: Ratio-over-input profile
When the intron splicing sites are focus of studies, we want to inspect signals at both 5’ splicing sites and 3’ splicing sites, perhaps want to contrast with the center of introns as well, then displaying all 3 pieces of information in the same panel would be desirable.
queryfiles <- system.file("extdata", "treat_chr19.bam", package = "GenomicPlot")
names(queryfiles) <- "clip_bam"
inputfiles <- system.file("extdata", "input_chr19.bam", package = "GenomicPlot")
names(inputfiles) <- "clip_input"
ext <- c(-500, 200, -200, 500)
hl <- c(-50, 50, -50, 50)
plot_start_end(
queryFiles = queryfiles,
inputFiles = inputfiles,
txdb = txdb,
centerFiles = "intron",
binSize = 10,
importParams = bamimportParams,
ext = ext,
hl = hl,
insert = 100,
stranded = TRUE,
scale = FALSE,
smooth = TRUE,
outPrefix = NULL,
nc = 5
)
Figure 6: Query and input sample profiles in start, center and end of intron
Figure 7: Ratio-over profile in start, center and end of intron
Difference in signal intensity within specific regions around the reference loci can be tested, and the test statistics can be plotted as boxplot and barplot of mean +/- SE. The test can be done among loci or among samples.
centerfiles <- c(
system.file("extdata", "test_clip_peak_chr19.bed", package = "GenomicPlot"),
system.file("extdata", "test_chip_peak_chr19.bed", package = "GenomicPlot")
)
names(centerfiles) <- c("iCLIPPeak", "SummitPeak")
queryfiles <- c(
system.file("extdata", "chip_treat_chr19.bam", package = "GenomicPlot")
)
names(queryfiles) <- c("chip_bam")
inputfiles <- c(
system.file("extdata", "chip_input_chr19.bam", package = "GenomicPlot")
)
names(inputfiles) <- c("chip_input")
plot_locus(
queryFiles = queryfiles,
centerFiles = centerfiles,
ext = c(-500, 500),
hl = c(-100, 100),
shade = TRUE,
smooth = TRUE,
importParams = chipimportParams,
binSize = 10,
refPoint = "center",
Xlab = "Center",
inputFiles = inputfiles,
stranded = TRUE,
scale = FALSE,
outPrefix = NULL,
verbose = FALSE,
transform = NA,
rmOutlier = 0,
statsMethod = "wilcox.test",
heatmap = TRUE,
nc = 5
)
Figure 8: Ratio-over-input profile around chip peaks and clip peaks
Figure 9: Ratio-over-input stats around chip peaks and clip peaks
Random sites that deviate from the reference loci within a specified maximum distance can be treated as a control, and the statistical tests will be performed between bona fide and the random sites. Here the reference sites located in different genomic features (5’UTR, CDS, 3’UTR) are tested separately. To avoid sampling bias, increase “n_random”.
centerfiles <- c(system.file("extdata", "test_clip_peak_chr19.bed",
package = "GenomicPlot"))
names(centerfiles) <- c("iCLIPPeak")
queryfiles <- c(system.file("extdata", "treat_chr19.bam",
package = "GenomicPlot"))
names(queryfiles) <- c("clip_bam")
inputfiles <- c(system.file("extdata", "input_chr19.bam",
package = "GenomicPlot"))
names(inputfiles) <- c("clip_input")
plot_locus_with_random(
queryFiles = queryfiles,
centerFiles = centerfiles,
txdb,
ext = c(-500, 500),
hl = c(-100, 100),
shade = TRUE,
importParams = bamimportParams,
binSize = 10,
refPoint = "center",
Xlab = "Center",
smooth = TRUE,
inputFiles = inputfiles,
stranded = TRUE,
scale = FALSE,
outPrefix = NULL,
verbose = FALSE,
transform = NA,
rmOutlier = 0,
n_random = 1,
statsMethod = "wilcox.test",
nc = 5
)
Figure 10: Ratio-over-input for clip signal around clip peaks in 5’UTR
Figure 11: Ratio-over-input for clip signal around clip peaks in 5’UTR
Aside from reads coverage profiles, distribution of binding peaks in different gene types and genomic features is also important. Peak annotation statistics are plotted as bar chart for distribution in gene types, and as pie charts for distribution in genomic features. The pie charts are plotted in two different ways: either as percentage of absolute counts or as percentage of feature length-normalized counts in each features. For DNA binding samples, the features (in order of precedence) include “Promoter”, “TTS”, “5’UTR”, “CDS”, “3’UTR” and “Intron”; for RNA binding samples, “Promoter” and “TTS” are excluded. In the following example, “Promoter” is defined as regions 2000 bp upstream of transcription start site (TSS) and 300 bp downstream TSS, “TTS” is defined as the region 1000 bp downstream cleavage site or the length between cleavage site and the start of the next gene, whichever is shorter, but these lengths can be adjusted. To save annotation results (both peak-oriented and gene-oriented), set “verbose = TRUE”.
gtffile <- system.file("extdata", "gencode.v19.annotation_chr19.gtf",
package = "GenomicPlot")
centerfile <- system.file("extdata", "test_chip_peak_chr19.bed",
package = "GenomicPlot")
names(centerfile) <- c("SummitPeak")
bedimportParams <- list(
offset = 0, fix_width = 100, fix_point = "center", norm = FALSE,
useScore = FALSE, outRle = TRUE, useSizeFactor = FALSE, genome = "hg19"
)
pa <- plot_peak_annotation(
peakFile = centerfile,
gtfFile = gtffile,
importParams = bedimportParams,
fiveP = -2000,
dsTSS = 300,
threeP = 1000,
simple = FALSE,
verbose = TRUE,
outPrefix = NULL
)
Figure 12: Distribution of chip peak in various types of gene
Figure 13: Distribution of chip peak in various parts of gene
Here is the output of sessionInfo() on the system on which this document was
compiled:
## R version 4.2.1 (2022-06-23 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19044)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=C
## [2] LC_CTYPE=English_United States.utf8
## [3] LC_MONETARY=English_United States.utf8
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.utf8
##
## attached base packages:
## [1] stats4 stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] BiocStyle_2.26.0 GenomicPlot_0.99.5 GenomicFeatures_1.49.7
## [4] AnnotationDbi_1.59.1 Biobase_2.57.1 GenomicRanges_1.49.0
## [7] GenomeInfoDb_1.33.10 IRanges_2.31.2 S4Vectors_0.35.4
## [10] BiocGenerics_0.43.4
##
## loaded via a namespace (and not attached):
## [1] utf8_1.2.3 tidyselect_1.2.0
## [3] RSQLite_2.3.1 htmlwidgets_1.6.2
## [5] grid_4.2.1 ranger_0.15.1
## [7] BiocParallel_1.31.13 devtools_2.4.5
## [9] munsell_0.5.0 codetools_0.2-19
## [11] DT_0.28 miniUI_0.1.1.1
## [13] withr_2.5.0 colorspace_2.1-0
## [15] filelock_1.0.2 highr_0.10
## [17] knitr_1.42 rstudioapi_0.14
## [19] ggsignif_0.6.4 MatrixGenerics_1.9.1
## [21] GenomeInfoDbData_1.2.9 seqPattern_1.29.0
## [23] bit64_4.0.5 pheatmap_1.0.12
## [25] rprojroot_2.0.3 vctrs_0.6.2
## [27] generics_0.1.3 lambda.r_1.2.4
## [29] xfun_0.39 BiocFileCache_2.5.2
## [31] ggseqlogo_0.1 R6_2.5.1
## [33] doParallel_1.0.17 clue_0.3-64
## [35] locfit_1.5-9.7 bitops_1.0-7
## [37] cachem_1.0.8 gridGraphics_0.5-1
## [39] DelayedArray_0.23.2 promises_1.2.0.1
## [41] BiocIO_1.7.1 scales_1.2.1
## [43] gtable_0.3.3 processx_3.8.1
## [45] rlang_1.1.1 GlobalOptions_0.1.2
## [47] rstatix_0.7.2 rtracklayer_1.57.0
## [49] lazyeval_0.2.2 impute_1.71.0
## [51] broom_1.0.4 plyranges_1.17.0
## [53] BiocManager_1.30.20 abind_1.4-5
## [55] yaml_2.3.7 reshape2_1.4.4
## [57] backports_1.4.1 httpuv_1.6.11
## [59] RCAS_1.23.0 tools_4.2.1
## [61] usethis_2.1.6 bookdown_0.34
## [63] ggplotify_0.1.0 gridBase_0.4-7
## [65] ggplot2_3.4.2 ellipsis_0.3.2
## [67] jquerylib_0.1.4 RColorBrewer_1.1-3
## [69] proxy_0.4-27 sessioninfo_1.2.2
## [71] Rcpp_1.0.10 plyr_1.8.8
## [73] progress_1.2.2 zlibbioc_1.43.0
## [75] purrr_1.0.1 RCurl_1.98-1.12
## [77] ps_1.7.5 prettyunits_1.1.1
## [79] ggpubr_0.6.0 pbapply_1.7-0
## [81] GetoptLong_1.0.5 viridis_0.6.3
## [83] cowplot_1.1.1 urlchecker_1.0.1
## [85] SummarizedExperiment_1.27.3 cluster_2.1.4
## [87] fs_1.6.2 magrittr_2.0.3
## [89] data.table_1.14.8 futile.options_1.0.1
## [91] circlize_0.4.15 matrixStats_0.63.0
## [93] pkgload_1.3.2 hms_1.1.3
## [95] mime_0.12 evaluate_0.21
## [97] xtable_1.8-4 XML_3.99-0.14
## [99] VennDiagram_1.7.3 gridExtra_2.3
## [101] shape_1.4.6 compiler_4.2.1
## [103] biomaRt_2.53.3 tibble_3.2.1
## [105] KernSmooth_2.23-21 crayon_1.5.2
## [107] BSgenome.Hsapiens.UCSC.hg19_1.4.3 htmltools_0.5.5
## [109] later_1.3.1 tzdb_0.4.0
## [111] tidyr_1.3.0 DBI_1.1.3
## [113] formatR_1.14 genomation_1.29.0
## [115] gprofiler2_0.2.1 dbplyr_2.3.2
## [117] ComplexHeatmap_2.13.3 rappdirs_0.3.3
## [119] car_3.1-2 Matrix_1.5-4.1
## [121] readr_2.1.4 cli_3.6.1
## [123] parallel_4.2.1 forcats_1.0.0
## [125] pkgconfig_2.0.3 GenomicAlignments_1.33.1
## [127] plotly_4.10.1 xml2_1.3.4
## [129] roxygen2_7.2.3 foreach_1.5.2
## [131] bslib_0.4.2 XVector_0.37.1
## [133] yulab.utils_0.0.6 stringr_1.5.0
## [135] callr_3.7.3 digest_0.6.31
## [137] Biostrings_2.65.6 rmarkdown_2.21
## [139] edgeR_3.39.6 restfulr_0.0.15
## [141] curl_5.0.0 shiny_1.7.4
## [143] Rsamtools_2.13.4 rjson_0.2.21
## [145] lifecycle_1.0.3 jsonlite_1.8.4
## [147] carData_3.0-5 futile.logger_1.4.3
## [149] desc_1.4.2 viridisLite_0.4.2
## [151] limma_3.53.10 BSgenome_1.65.2
## [153] fansi_1.0.4 pillar_1.9.0
## [155] ggsci_3.0.0 lattice_0.21-8
## [157] KEGGREST_1.37.3 fastmap_1.1.1
## [159] httr_1.4.6 plotrix_3.8-2
## [161] pkgbuild_1.4.0 glue_1.6.2
## [163] remotes_2.4.2 png_0.1-8
## [165] iterators_1.0.14 bit_4.0.5
## [167] sass_0.4.6 stringi_1.7.12
## [169] profvis_0.3.8 blob_1.2.4
## [171] memoise_2.0.1 dplyr_1.1.2